import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("member", { schema: "charge" })
export class Member {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", { name: "account", length: 30 })
  account: string;

  @Column("char", { name: "password", length: 64 })
  password: string;

  @Column("char", { name: "salt", length: 12 })
  salt: string;

  @Column("tinyint", { name: "belong", comment: "归属", default: () => "'0'" })
  belong: number;

  @Column("int", { name: "creator_id", default: () => "'0'" })
  creatorId: number;

  @Column("int", { name: "merchant_id", default: () => "'0'" })
  merchantId: number;

  @Column("int", { name: "direct_leader", default: () => "'0'" })
  directLeader: number;

  @Column("int", { name: "dept_id", default: () => "'0'" })
  deptId: number;

  @Column("varchar", { name: "name", length: 30 })
  name: string;

  @Column("varchar", { name: "tel", length: 11 })
  tel: string;

  @Column("boolean", { name: "can_super"})
  canSuper: boolean;

  @Column("json", { name: "roles", nullable: true, comment: "角色" })
  roles: number[];

  @Column("varchar", { name: "remark", length: 100 })
  remark: string;

  @Column("boolean", { name: "enable"})
  enable: boolean;

  @Column("int", { name: "create_time", default: () => "'0'" })
  createTime: number;

  @Column("int", { name: "update_time", default: () => "'0'" })
  updateTime: number;

  @Column("int", {
    name: "last_login_time",
    unsigned: true,
    default: () => "'0'",
  })
  lastLoginTime: number;

  @Column("varchar", { name: "last_ip", nullable: true, length: 128 })
  lastIp: string | null;
}
